/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package org.gui.przedmioty;

import db.models.GrupaOcen;
import java.awt.Color;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.JButton;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;

/**
 *
 * @author Mariushrek
 */
public class GrupaOcenDodajPanel extends javax.swing.JPanel implements KeyListener, MouseListener{
    JButton parent_OK_Button = null;
    /**
     * Creates new form GrupaOcenDodaj
     */
    public GrupaOcenDodajPanel(JButton k_parent_OK_Button) {
        initComponents();
        inicjacja_podkategorii();
        this.parent_OK_Button = k_parent_OK_Button;
        clean();
    }
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        pod_03 = new javax.swing.JTextField();
        label_03 = new javax.swing.JLabel();
        pod_02 = new javax.swing.JTextField();
        label_02 = new javax.swing.JLabel();
        pod_05 = new javax.swing.JTextField();
        label_05 = new javax.swing.JLabel();
        pod_04 = new javax.swing.JTextField();
        label_04 = new javax.swing.JLabel();
        wag_02 = new javax.swing.JFormattedTextField();
        wag_01 = new javax.swing.JFormattedTextField();
        label_13 = new javax.swing.JLabel();
        pod_13 = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        wag_13 = new javax.swing.JFormattedTextField();
        pod_12 = new javax.swing.JTextField();
        label_12 = new javax.swing.JLabel();
        pod_11 = new javax.swing.JTextField();
        label_11 = new javax.swing.JLabel();
        pod_01 = new javax.swing.JTextField();
        label_01 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        waga_all = new javax.swing.JLabel();
        label_07 = new javax.swing.JLabel();
        pod_08 = new javax.swing.JTextField();
        label_08 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        pod_09 = new javax.swing.JTextField();
        jPanel1 = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        add = new javax.swing.JButton();
        rmv = new javax.swing.JButton();
        label_09 = new javax.swing.JLabel();
        pod_10 = new javax.swing.JTextField();
        label_10 = new javax.swing.JLabel();
        wag_12 = new javax.swing.JFormattedTextField();
        wag_09 = new javax.swing.JFormattedTextField();
        jLabel6 = new javax.swing.JLabel();
        wag_08 = new javax.swing.JFormattedTextField();
        wag_11 = new javax.swing.JFormattedTextField();
        wag_10 = new javax.swing.JFormattedTextField();
        wag_04 = new javax.swing.JFormattedTextField();
        wag_05 = new javax.swing.JFormattedTextField();
        wag_06 = new javax.swing.JFormattedTextField();
        wag_07 = new javax.swing.JFormattedTextField();
        wag_03 = new javax.swing.JFormattedTextField();
        nazwa_kategorii = new javax.swing.JTextField();
        pod_06 = new javax.swing.JTextField();
        pod_07 = new javax.swing.JTextField();
        label_06 = new javax.swing.JLabel();

        pod_03.setText(org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.pod_03.text")); // NOI18N

        org.openide.awt.Mnemonics.setLocalizedText(label_03, org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.label_03.text")); // NOI18N

        pod_02.setText(org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.pod_02.text")); // NOI18N

        org.openide.awt.Mnemonics.setLocalizedText(label_02, org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.label_02.text")); // NOI18N

        pod_05.setText(org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.pod_05.text")); // NOI18N

        org.openide.awt.Mnemonics.setLocalizedText(label_05, org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.label_05.text")); // NOI18N

        pod_04.setText(org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.pod_04.text")); // NOI18N

        org.openide.awt.Mnemonics.setLocalizedText(label_04, org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.label_04.text")); // NOI18N

        wag_02.setText(org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.wag_02.text")); // NOI18N
        wag_02.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                wag_02KeyTyped(evt);
            }
        });

        wag_01.setText(org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.wag_01.text")); // NOI18N
        wag_01.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                wag_01KeyTyped(evt);
            }
        });

        org.openide.awt.Mnemonics.setLocalizedText(label_13, org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.label_13.text")); // NOI18N

        pod_13.setText(org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.pod_13.text")); // NOI18N

        org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.jLabel1.text")); // NOI18N

        wag_13.setText(org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.wag_13.text")); // NOI18N
        wag_13.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                wag_13KeyTyped(evt);
            }
        });

        pod_12.setText(org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.pod_12.text")); // NOI18N

        org.openide.awt.Mnemonics.setLocalizedText(label_12, org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.label_12.text")); // NOI18N

        pod_11.setText(org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.pod_11.text")); // NOI18N

        org.openide.awt.Mnemonics.setLocalizedText(label_11, org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.label_11.text")); // NOI18N

        pod_01.setText(org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.pod_01.text")); // NOI18N

        org.openide.awt.Mnemonics.setLocalizedText(label_01, org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.label_01.text")); // NOI18N

        jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.jLabel2.text")); // NOI18N

        waga_all.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        waga_all.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        org.openide.awt.Mnemonics.setLocalizedText(waga_all, org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.waga_all.text")); // NOI18N

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(waga_all, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(waga_all)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        org.openide.awt.Mnemonics.setLocalizedText(label_07, org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.label_07.text")); // NOI18N

        pod_08.setText(org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.pod_08.text")); // NOI18N

        org.openide.awt.Mnemonics.setLocalizedText(label_08, org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.label_08.text")); // NOI18N

        org.openide.awt.Mnemonics.setLocalizedText(jLabel5, org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.jLabel5.text")); // NOI18N

        pod_09.setText(org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.pod_09.text")); // NOI18N

        jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        org.openide.awt.Mnemonics.setLocalizedText(jLabel4, org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.jLabel4.text")); // NOI18N

        org.openide.awt.Mnemonics.setLocalizedText(add, org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.add.text")); // NOI18N
        add.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addActionPerformed(evt);
            }
        });

        org.openide.awt.Mnemonics.setLocalizedText(rmv, org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.rmv.text")); // NOI18N
        rmv.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rmvActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(add, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(rmv, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(add)
                    .addComponent(rmv))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        org.openide.awt.Mnemonics.setLocalizedText(label_09, org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.label_09.text")); // NOI18N

        pod_10.setText(org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.pod_10.text")); // NOI18N

        org.openide.awt.Mnemonics.setLocalizedText(label_10, org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.label_10.text")); // NOI18N

        wag_12.setText(org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.wag_12.text")); // NOI18N
        wag_12.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                wag_12KeyTyped(evt);
            }
        });

        wag_09.setText(org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.wag_09.text")); // NOI18N
        wag_09.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                wag_09KeyTyped(evt);
            }
        });

        org.openide.awt.Mnemonics.setLocalizedText(jLabel6, org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.jLabel6.text")); // NOI18N

        wag_08.setText(org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.wag_08.text")); // NOI18N
        wag_08.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                wag_08KeyTyped(evt);
            }
        });

        wag_11.setText(org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.wag_11.text")); // NOI18N
        wag_11.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                wag_11KeyTyped(evt);
            }
        });

        wag_10.setText(org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.wag_10.text")); // NOI18N
        wag_10.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                wag_10KeyTyped(evt);
            }
        });

        wag_04.setText(org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.wag_04.text")); // NOI18N
        wag_04.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                wag_04KeyTyped(evt);
            }
        });

        wag_05.setText(org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.wag_05.text")); // NOI18N
        wag_05.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                wag_05KeyTyped(evt);
            }
        });

        wag_06.setText(org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.wag_06.text")); // NOI18N
        wag_06.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                wag_06KeyTyped(evt);
            }
        });

        wag_07.setText(org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.wag_07.text")); // NOI18N
        wag_07.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                wag_07KeyTyped(evt);
            }
        });

        wag_03.setText(org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.wag_03.text")); // NOI18N
        wag_03.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                wag_03KeyTyped(evt);
            }
        });

        nazwa_kategorii.setText(org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.nazwa_kategorii.text")); // NOI18N

        pod_06.setText(org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.pod_06.text")); // NOI18N

        pod_07.setText(org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.pod_07.text")); // NOI18N

        org.openide.awt.Mnemonics.setLocalizedText(label_06, org.openide.util.NbBundle.getMessage(GrupaOcenDodajPanel.class, "GrupaOcenDodajPanel.label_06.text")); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(nazwa_kategorii, javax.swing.GroupLayout.PREFERRED_SIZE, 294, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addGroup(layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel1))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                        .addComponent(label_02)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(pod_02))
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                        .addComponent(label_03)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(pod_03, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                        .addComponent(label_01)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(layout.createSequentialGroup()
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, 163, Short.MAX_VALUE))
                                            .addGroup(layout.createSequentialGroup()
                                                .addGap(4, 4, 4)
                                                .addComponent(pod_01)))))
                                .addGap(4, 4, 4)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, 115, Short.MAX_VALUE)
                                    .addComponent(wag_01)
                                    .addComponent(wag_03)
                                    .addComponent(wag_02)))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(label_04)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(pod_04, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(wag_04, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(label_05)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(pod_05, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(wag_05, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(label_06)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(pod_06, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(wag_06, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(label_07)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(pod_07, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(wag_07, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(label_08)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(pod_08, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(wag_08, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                    .addComponent(label_12)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(pod_12, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(wag_12))
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                    .addComponent(label_11)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(pod_11, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(wag_11))
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                    .addComponent(label_10)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(pod_10, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(wag_10))
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                    .addComponent(label_09)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(pod_09, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(wag_09, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                    .addComponent(label_13)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(pod_13, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(wag_13))))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(nazwa_kategorii, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(jLabel6))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(label_01)
                    .addComponent(pod_01, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(wag_01, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(label_02)
                    .addComponent(pod_02, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(wag_02, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(label_03)
                    .addComponent(pod_03, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(wag_03, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(label_04)
                    .addComponent(pod_04, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(wag_04, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(label_05)
                    .addComponent(pod_05, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(wag_05, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(label_06)
                    .addComponent(pod_06, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(wag_06, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(label_07)
                    .addComponent(pod_07, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(wag_07, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(label_08)
                    .addComponent(pod_08, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(wag_08, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(label_09)
                    .addComponent(pod_09, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(wag_09, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(label_10)
                    .addComponent(pod_10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(wag_10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(label_11)
                    .addComponent(pod_11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(wag_11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(label_12)
                    .addComponent(pod_12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(wag_12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(label_13)
                    .addComponent(pod_13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(wag_13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void wag_02KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_wag_02KeyTyped
        isDigitInside(evt);
    }//GEN-LAST:event_wag_02KeyTyped

    private void wag_01KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_wag_01KeyTyped
        isDigitInside(evt);
    }//GEN-LAST:event_wag_01KeyTyped

    private void wag_13KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_wag_13KeyTyped
        isDigitInside(evt);
    }//GEN-LAST:event_wag_13KeyTyped

    private void addActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addActionPerformed
        if(ilosc_podkategorii_aktywnych < ilosc_podkategorii_wszystkich) {
            ilosc_podkategorii_aktywnych++;
            generuj_podkategorie();
        }
        if(ilosc_podkategorii_aktywnych == 1) { rmv.setEnabled(false); } else { rmv.setEnabled(true); }
        if(ilosc_podkategorii_aktywnych == ilosc_podkategorii_wszystkich) { add.setEnabled(false); } else { add.setEnabled(true); }
    }//GEN-LAST:event_addActionPerformed

    private void rmvActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rmvActionPerformed
        if(ilosc_podkategorii_aktywnych > 1) {
            ilosc_podkategorii_aktywnych--;
            generuj_podkategorie();
        }
        if(ilosc_podkategorii_aktywnych == 1) { rmv.setEnabled(false); } else { rmv.setEnabled(true); }
        if(ilosc_podkategorii_aktywnych == ilosc_podkategorii_wszystkich) { add.setEnabled(false); } else { add.setEnabled(true); }
    }//GEN-LAST:event_rmvActionPerformed

    private void wag_12KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_wag_12KeyTyped
        isDigitInside(evt);
    }//GEN-LAST:event_wag_12KeyTyped

    private void wag_09KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_wag_09KeyTyped
        isDigitInside(evt);
    }//GEN-LAST:event_wag_09KeyTyped

    private void wag_08KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_wag_08KeyTyped
        isDigitInside(evt);
    }//GEN-LAST:event_wag_08KeyTyped

    private void wag_11KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_wag_11KeyTyped
        isDigitInside(evt);
    }//GEN-LAST:event_wag_11KeyTyped

    private void wag_10KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_wag_10KeyTyped
        isDigitInside(evt);
    }//GEN-LAST:event_wag_10KeyTyped

    private void wag_04KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_wag_04KeyTyped
        isDigitInside(evt);
    }//GEN-LAST:event_wag_04KeyTyped

    private void wag_05KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_wag_05KeyTyped
        isDigitInside(evt);
    }//GEN-LAST:event_wag_05KeyTyped

    private void wag_06KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_wag_06KeyTyped
        isDigitInside(evt);
    }//GEN-LAST:event_wag_06KeyTyped

    private void wag_07KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_wag_07KeyTyped
        isDigitInside(evt);
    }//GEN-LAST:event_wag_07KeyTyped

    private void wag_03KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_wag_03KeyTyped
        isDigitInside(evt);
    }//GEN-LAST:event_wag_03KeyTyped


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton add;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JLabel label_01;
    private javax.swing.JLabel label_02;
    private javax.swing.JLabel label_03;
    private javax.swing.JLabel label_04;
    private javax.swing.JLabel label_05;
    private javax.swing.JLabel label_06;
    private javax.swing.JLabel label_07;
    private javax.swing.JLabel label_08;
    private javax.swing.JLabel label_09;
    private javax.swing.JLabel label_10;
    private javax.swing.JLabel label_11;
    private javax.swing.JLabel label_12;
    private javax.swing.JLabel label_13;
    private javax.swing.JTextField nazwa_kategorii;
    private javax.swing.JTextField pod_01;
    private javax.swing.JTextField pod_02;
    private javax.swing.JTextField pod_03;
    private javax.swing.JTextField pod_04;
    private javax.swing.JTextField pod_05;
    private javax.swing.JTextField pod_06;
    private javax.swing.JTextField pod_07;
    private javax.swing.JTextField pod_08;
    private javax.swing.JTextField pod_09;
    private javax.swing.JTextField pod_10;
    private javax.swing.JTextField pod_11;
    private javax.swing.JTextField pod_12;
    private javax.swing.JTextField pod_13;
    private javax.swing.JButton rmv;
    private javax.swing.JFormattedTextField wag_01;
    private javax.swing.JFormattedTextField wag_02;
    private javax.swing.JFormattedTextField wag_03;
    private javax.swing.JFormattedTextField wag_04;
    private javax.swing.JFormattedTextField wag_05;
    private javax.swing.JFormattedTextField wag_06;
    private javax.swing.JFormattedTextField wag_07;
    private javax.swing.JFormattedTextField wag_08;
    private javax.swing.JFormattedTextField wag_09;
    private javax.swing.JFormattedTextField wag_10;
    private javax.swing.JFormattedTextField wag_11;
    private javax.swing.JFormattedTextField wag_12;
    private javax.swing.JFormattedTextField wag_13;
    private javax.swing.JLabel waga_all;
    // End of variables declaration//GEN-END:variables

   private int ilosc_podkategorii_wszystkich = 13;
    private int ilosc_podkategorii_aktywnych = 1;
    private javax.swing.JLabel labels[] = new javax.swing.JLabel[ilosc_podkategorii_wszystkich];
    private javax.swing.JTextField podkategorie[] = new javax.swing.JTextField[ilosc_podkategorii_wszystkich];
    private javax.swing.JFormattedTextField wagi[] = new javax.swing.JFormattedTextField[ilosc_podkategorii_wszystkich];
    
    private void inicjacja_podkategorii() {
        podkategorie[0] = pod_01;
        podkategorie[1] = pod_02;
        podkategorie[2] = pod_03;
        podkategorie[3] = pod_04;
        podkategorie[4] = pod_05;
        podkategorie[5] = pod_06;
        podkategorie[6] = pod_07;
        podkategorie[7] = pod_08;
        podkategorie[8] = pod_09;
        podkategorie[9] = pod_10;
        podkategorie[10] = pod_11;
        podkategorie[11] = pod_12;
        podkategorie[12] = pod_13;
        
        wagi[0] = wag_01;
        wagi[1] = wag_02;
        wagi[2] = wag_03;
        wagi[3] = wag_04;
        wagi[4] = wag_05;
        wagi[5] = wag_06;
        wagi[6] = wag_07;
        wagi[7] = wag_08;
        wagi[8] = wag_09;
        wagi[9] = wag_10;
        wagi[10] = wag_11;
        wagi[11] = wag_12;
        wagi[12] = wag_13;
     
        DocumentListener wagi_aktualizacja = new DocumentListener() {
            @Override
            public void insertUpdate(DocumentEvent de) {
                ZliczanieWagi();
            }

            @Override
            public void removeUpdate(DocumentEvent de) {
                ZliczanieWagi();
            }

            @Override
            public void changedUpdate(DocumentEvent de) {
                ZliczanieWagi();
            }
        };
                
        for(int i=0; i<ilosc_podkategorii_wszystkich; i++) {
            wagi[i].getDocument().addDocumentListener(wagi_aktualizacja);
        }
        
    }
    
    private void generuj_podkategorie() {           
        for (int i = 1; i <ilosc_podkategorii_aktywnych; i++) {
            podkategorie[i].setEnabled(true);
            wagi[i].setEnabled(true);           
        }
        
        for (int i = ilosc_podkategorii_aktywnych; i <ilosc_podkategorii_wszystkich; i++) {
            podkategorie[i].setText("");
            podkategorie[i].setEnabled(false);
            
            wagi[i].setText("");
            wagi[i].setEnabled(false);           
        }      
    }
    
    private void ZliczanieWagi() {
        double suma = 0.;
        for (int i=0; i<ilosc_podkategorii_aktywnych; i++) {
            String teraz = wagi[i].getText();
            double liczba=0.;
            if(!teraz.equals("")) {
                liczba = Double.parseDouble(teraz);
            }
            suma+= liczba;
        }
        if(suma <= 100.0 && suma >=0.0) {
            jPanel2.setBackground(new Color(240,240,240));
        } else
        if(suma > 100.0) {
            jPanel2.setBackground(new Color(255,0,0));
        } else 
        if(suma < 0.0) {
            jPanel2.setBackground(new Color(255,0,0));
        }
        waga_all.setText(suma+"%");
    }
    private void isDigitInside(java.awt.event.KeyEvent evt) {
        char c = evt.getKeyChar();
        if(!(Character.isDigit(c)) || (c==KeyEvent.VK_BACK_SPACE) || (c==KeyEvent.VK_DELETE) || c==KeyEvent.VK_PERIOD) {
            evt.consume();
        }
    }
    public int SaveAll() {
        int id_kategorii;
        // Sprawdzenie, czy podkategorie i wagi sa wypelnione
        boolean czy_wypelnione_podkategorie = true;
        for (int i=0; i < ilosc_podkategorii_aktywnych; i++) {
            if(podkategorie[i].getText().equals("") || wagi[i].getText().equals("")) {
                czy_wypelnione_podkategorie = false;
            }
        }
        if(!nazwa_kategorii.getText().equals("") && waga_all.getText().equals("100.0%") && czy_wypelnione_podkategorie == true) {
            // Dodanie glownej kategorii
            id_kategorii = GrupaOcen.addGrupaOcen(0, nazwa_kategorii.getText() , 1);
            // Dodanie podkategorii
            if(id_kategorii !=0) {
                for (int i=0; i < ilosc_podkategorii_aktywnych; i++) {
                    GrupaOcen.addGrupaOcen(id_kategorii, podkategorie[i].getText(), (Float.parseFloat(wagi[i].getText())/100));
                }
                return id_kategorii;
            } 
        } 
        return 0;
    }
    
    public void clean() {
        nazwa_kategorii.setText("");
        ilosc_podkategorii_aktywnych = 1;
        rmv.setEnabled(false);
        for (int i = 0; i <ilosc_podkategorii_wszystkich; i++) {
            podkategorie[i].setEnabled(false);
            wagi[i].setEnabled(false); 
            podkategorie[i].setText("");
            wagi[i].setText("");
            podkategorie[i].addKeyListener(this);
            wagi[i].addKeyListener(this);
        }     
        podkategorie[0].setEnabled(true);
        wagi[0].setEnabled(true);
        nazwa_kategorii.addKeyListener(this);
        add.addMouseListener(this);
        rmv.addMouseListener(this);
    }
    
    private void validator() {
        boolean czy_wypelnione_podkategorie = true;
        for (int i=0; i < ilosc_podkategorii_aktywnych; i++) {
            if(podkategorie[i].getText().equals("") || wagi[i].getText().equals("")) {
                czy_wypelnione_podkategorie = false;
            }
        }
        boolean czy_wypelniona_kategoria = false;
        if(!nazwa_kategorii.getText().equals("")) czy_wypelniona_kategoria = true;
        boolean czy_suma_wag = false;
        if(waga_all.getText().equals("100.0%")) czy_suma_wag = true; 
        
        if(czy_wypelnione_podkategorie && czy_wypelniona_kategoria && czy_suma_wag) {
            parent_OK_Button.setEnabled(true);
        } else {
            parent_OK_Button.setEnabled(false);
        }
    }

    @Override    public void keyTyped(KeyEvent ke) { validator(); }
    @Override    public void keyPressed(KeyEvent ke) { validator(); }
    @Override    public void keyReleased(KeyEvent ke) { validator(); }
    @Override    public void mouseClicked(MouseEvent me) {}
    @Override    public void mousePressed(MouseEvent me) {}
    @Override    public void mouseReleased(MouseEvent me) { validator(); }
    @Override    public void mouseEntered(MouseEvent me) {}
    @Override    public void mouseExited(MouseEvent me) {}
}
